//
//  TableViewController.m
//  FontFamily
//
//  Created by Wai Cheung Chiu on 16/10/20.
//  Copyright © 2016年 Wai Cheung Chiu. All rights reserved.
//

#import "TableViewController.h"

@interface TableViewController ()
@property(strong,nonatomic)NSArray *fontArray;
@property(strong,nonatomic)NSMutableArray *dataArray;
@end

@implementation TableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataArray=[[NSMutableArray alloc]init];
    _fontArray=[[NSArray alloc]init];
    _fontArray=[UIFont familyNames];
    for (NSString *item in _fontArray) {
        NSLog(@"%@",item);
        NSArray *fonts=[UIFont fontNamesForFamilyName:item];
        NSLog(@"%@",fonts);
        for (NSString *fontsName in fonts) {
            [_dataArray addObject:fontsName];
            
        }
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuseId=@"fontCell";
    UITableViewCell *cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:reuseId];
//    if (cell==nil) {
//        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:reuseId];
//    }
//    cell.textLabel.text=_dataArray[indexPath.row];
//    cell.detailTextLabel.text=@"LXPlxp123李锡鹏";
//    cell.detailTextLabel.font=[UIFont fontWithName:_dataArray[indexPath.row] size:14.0f];

    UITextField *text=[[UITextField  alloc]initWithFrame:CGRectMake(0, 0, 200, 44)];
    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(200, 0, 110, 34)];
    text.delegate=self;
    text.text=_dataArray[indexPath.row];
    label.text=@"LXPlxp12.3李锡鹏";
    label.textAlignment=NSTextAlignmentCenter;
    label.layer.backgroundColor=[UIColor whiteColor].CGColor;
    label.layer.cornerRadius=8.0;
    label.layer.masksToBounds=NO;//yes的话阴影就没效果,要使用阴影就设置为NO
    label.layer.borderWidth=0.5;
    label.layer.shadowOffset=CGSizeMake(0, 3);
    label.layer.shadowRadius=10.0;
    label.layer.shadowColor=[UIColor blackColor].CGColor;
    label.layer.shadowOpacity=1.0;
    label.layer.borderColor=[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1].CGColor; 
    label.font=[UIFont fontWithName:_dataArray[indexPath.row] size:12.0f];
    [cell addSubview:text];
    [cell addSubview:label];
    return cell;
}


/*
 // Override to support conditional editing of the table view.
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the specified item to be editable.
 return YES;
 }
 */

/*
 // Override to support editing the table view.
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 // Delete the row from the data source
 [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
 } else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }
 }
 */

/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
 */

/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return  YES;
}
@end
